#!D:/CODE/python
# -*- coding: utf-8 -*-
# @Time : 2020/5/25 15:52
# @Author : Alexdong
# @Site : 
# @File : 使用yield完成多任务.py
# @Software: PyCharm
# Functional description:

import time

def task_1():
    while True:
        print("---1")
        time.sleep(0.1)
        yield

def task_2():
    while True:
        print("---2")
        time.sleep(0.1)
        yield

def main():
    t1 = task_1()
    t2 = task_2()
    while True:
        next(t1)
        next(t2)


if __name__ == "__main__":
    main()